10  ' mandelx3.bas - FreeWare 2005
20 GOTO 60 ' begin
30 'SAVE "mandelx3.bas",A:LIST-50
40 GOTO 370 ' wait for key
50 GOTO 400 ' centered text
60 SCREEN 12:CLS:DEFSTR M,Q:Q=MKI$(0)
70 DEFDBL A,B,D,X,Y,S:WINDOW (-320,-240)-(319,239)
80 DELH=.8:DELV=.8:N1=200:N2=INT(N1*DELV/DELH)
90 M(1)="MANDELBROT idea from Hans Lauwerier"
100 M(2)="GWBASIC by Eric Tchong"
110 M(3)="Press any key to generate fractal"
120 FOR I=1 TO 3
130  GOSUB 50
140  IF I=2 THEN PRINT
150 NEXT:GOSUB 40:CLS
160 FOR I=0 TO N1:A=I*DELH/N1
170  FOR J=0 TO N2:B=J*DELV/N2
180   X=1:Y=0
190   FOR K=1 TO 100
200    S=X*X+Y*Y:S2=S*S+1E-08
210    IF S>64 THEN L=1+K MOD 14:K=2005:GOTO 260
220    X2=X*X-Y*Y:Y2=2*X*Y
230    XR=X2/S2:YR=-Y2/S2
240    X1=X2+XR:Y1=Y2+YR
250    X=A*X1-B*Y1:Y=A*Y1+B*X1
260   NEXT
270   IF K=2006 THEN 290
280   L=9
290   PSET (I,J),L:PSET (I,-J),L
300   PSET (-I,J),L:PSET (-I,-J),L
310   IF INKEY$<>"" THEN 340
320  NEXT J
330 NEXT
340 GOSUB 40
350 SCREEN 0,0,0:CLS:END
360 ' wait for key
370 LSET Q=MKI$(0)
380 WHILE CVI(Q)=0:MID$(Q,1)=INKEY$:WEND:RETURN
390 ' centered text
400 X=(80-LEN(M(I)))/2
410 PRINT TAB(X) M(I):RETURN
